package com.campus.dao.provider;

import com.campus.pojo.SysArea;
import org.apache.ibatis.jdbc.SQL;

import java.util.List;
import java.util.Map;

public class AreaDynSqlProvider {
    public String getAreaList(Map<String,Object> params){
        String Sql = new SQL(){
            {
                SELECT("*");
                FROM("sys_area");
                if (params.get("area")!=null){
                    SysArea area = (SysArea) params.get("area");
                    if (area.getType().equals("1")){
                        WHERE("type = #{area.type}");
                    }else {
                        WHERE("parentId = #{area.parentId}");
                    }
                }
            }
        }.toString();
        //System.out.println(Sql);//调试
        return Sql;
    }
}
